package net.peelmeagrape.hibernate.collections;

import net.peelmeagrape.hibernate.xmlgen.*;
import net.peelmeagrape.hibernate.Meta;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Is to {@link CompositeElement} what {@link net.peelmeagrape.hibernate.Component} is to
 * an entity!
 */
@Target({METHOD,FIELD}) @Retention(RUNTIME)
@XmlElement(name="nested-composite-element")
@AddPropertyNameAsAttribute(name="name")
public @interface NestedCompositeElement
{
    @XmlAttribute("class")
            @DefaultFromPropertyType
            @ProcessTargetClass()
            Class[] targetClass() default {};

    /**
     * The strategy Hibernate should use for accessing the property value. This may be one of
     * 'property', 'field', 'embedded', or the name of a subclass of {@link org.hibernate.property.PropertyAccessor}.
     */
    @XmlAttribute String access() default "property";
    @XmlAttribute String node() default "";
    @ChildElement(0) Meta[] meta() default {};
}
